<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="/res/third/bootstrap3/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="/res/common/js/jquery.1.9.1.min.js" type="text/javascript"></script>
<script src="/res/third/artDialog/jquery.artDialog.js" type="text/javascript"></script>
<script src="/res/third/validate/jquery.validate.js" type="text/javascript"></script>
<script src="/res/third/laytpl/template.js"></script>
<script src="/res/common/js/jquery.form.js"></script>
<script src="/res/third/easyUI/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/res/third/easyUI/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
	<script type="text/javascript">
        function sosuo(){
            var lpath =location.pathname;
            var pageNo = 1;
            $("#soform").attr("action",lpath+"?pageNo="+pageNo);
            $("#soform").submit();
        }
        function changeValueDialog(companyId, companyName) {
            dialog = art.dialog({
                title: "奖惩成长值",
                lock: true,
                content: template("change_template", {'companyId': companyId, 'companyName': companyName}),
                okVal: "提交",
                ok: function () {
                    var changeValue = $("input[name='changeValue']").val();
                    if ($.trim(changeValue).length == 0 || !$.isNumeric(changeValue)) {
						alert("请填写正确的数值");
						return false;
					}
                    var changeReason = $("input[name='changeReason']").val();
					if($.trim(changeReason).length == 0) {
                        alert("请填写原因");
                        return false;
					}
                    var subData = $("#edit_form").serialize();
                    art.dialog.post({ url:"/level/user/change.do", data: subData, success:function(data){
                        if(data.success){
                            refresh();
                        }
                    }
                    });
                }
            });
        }
	</script>
	<script type="text/html" id="change_template">
		<form id="edit_form" style="width: 400px;" action="/level/config/save.do" method="post" class="form-horizontal" role="form">
			<input type="hidden" name="companyId" value="{{companyId}}">
			<div class="form-group">
				<label  class="col-sm-4 control-label">企业名称</label>
				<div class="col-sm-8">
					<label>{{companyName}}</label>
				</div>
			</div>
			<div class="form-group">
				<label  class="col-sm-4 control-label">成长值类型</label>
				<div class="col-sm-8">
					<select class="form-control" name="levelType">
						<option value="2">供应商成长值</option>
						<option value="1">采购商成长值</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label  class="col-sm-4 control-label">成长值变化</label>
				<div class="col-sm-8">
					<input type="radio" name="type" value="1" checked="checked">增加
					<input type="radio" name="type" value="-1">减少
				</div>
			</div>
			<div class="form-group">
				<label  class="col-sm-4 control-label">数值</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" placeholder="请输入数值" name="changeValue" value="{{changeValue}}">
				</div>
			</div>
			<div class="form-group">
				<label  class="col-sm-4 control-label">原因</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" placeholder="不超过 20 个字" maxlength="20" name="changeReason" value="{{changeReason}}">
				</div>
			</div>
		</form>
	</script>
</head>
<body>
	<div class="panel panel-info panel-content">
		<div class="panel-heading">
			<form id="soform" method="post">
				<table >
					<tr>
						<td class="w80" style="padding-top: 5px">
							<label for="companyname" class="center-block">企业名称：</label>
						</td>
						<td class="w150 ">
							<input type="text" class="form-control" name="so_companyName" value="${so_companyName!}" placeholder="企业名称" data-options="">
						</td>
						<td style="padding-left: 10px">
							<div class="input-group">
								<span class="input-group-btn">
									<button class="btn btn-default" type="button" onclick="sosuo()">搜索</button>
								</span>
							</div>
						</td>
					</tr>
				</table>
			</form>
		</div>
		<div class="panel-heading">
		</div>
		<table class="table table-hover table-bordered table-striped table-condensed">
			<tr>
				<th>#</th>
				<th>企业名称</th>
				<th>供应商成长值</th>
				<th>采购商成长值</th>
				<th>创建时间</th>
				<th>操作</th>
			</tr>
			[#list pagination.list as item]
			[@u_level companyId=item.companyId]
			<tr>
				<td align="center">${pagination.pageSize * (pagination.pageNo-1)+item_index+1}</td>
				<td align="center">${item.companyName!}</td>
				<td align="center">${item.providerValue!}[#if provider??](${provider.levelName!})[/#if]</td>
				<td align="center">${item.purchaseValue!}[#if purchase??](${purchase.levelName!})[/#if]</td>
				<td align="center">${item.createtime?string("yyyy-MM-dd HH:mm:ss")!}</td>
				<td align="center">
					<a href="/level/user/record.do?companyId=${item.companyId}"  class="btn btn-info btn-xs">详情</a>
					<button class="btn btn-info btn-xs" onclick="changeValueDialog('${item.companyId}', '${item.companyName!}');">奖惩</button>
				</td>
			</tr>
			[/@u_level]
			[/#list]
		</table>
		<div class="panel-footer">[@fenye p = pagination form = 'infoForm' /]</div>
	</div>
</body>
</html>
